package com.hooper.user.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hooper.hosp.model.user.UserInfo;
import com.hooper.hosp.vo.user.UserInfoQueryVo;
import com.hooper.hospital.common.result.Result;
import com.hooper.user.service.UserService;
import com.hooper.user.vo.UserVo;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2022/10/07/19:37
 */
@Api("user admin controller")
@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping("/admin/user")
public class UserController {
    private final UserService userService;


    @GetMapping("page/{currentPage}/{pageSize}")
    public Result<IPage<UserInfo>> pageResult(@PathVariable int currentPage,
                                              @PathVariable int pageSize,
                                              UserInfoQueryVo queryVo) {
        IPage<UserInfo> page = userService.pageByConditions(currentPage, pageSize, queryVo);
        return Result.ok(page);
    }

    @PostMapping("/lock/{id}/{status}")
    public Result lock(@PathVariable String id, @PathVariable Integer status) {
        userService.lock(id, status);
        return Result.ok();
    }

    @GetMapping("/detail/{id}")
    public Result<UserVo> userDetail(@PathVariable String id) {
        UserVo userInfo = userService.getUserDetail(id);
        return Result.ok(userInfo);
    }

    @GetMapping("approval/{userId}/{authStatus}")
    public Result approval(@PathVariable String userId, @PathVariable Integer authStatus) {
        userService.approval(userId, authStatus);
        return Result.ok();
    }
}
